#include "StandardIncludes.hpp"
#include "NetSocketAddress.hpp"

NNetLib::CSocketAddress::CSocketAddress() :
	m_address(0),
	m_port(0)
{
}

NNetLib::CSocketAddress::CSocketAddress(u32 address, u16 port) :
	m_address(address),
	m_port(port)
{
}

NNetLib::CSocketAddress::CSocketAddress(const std::string& address, u16 port) :
	m_port(port)
{
	m_address = inet_addr(address.c_str());
}

bool NNetLib::CSocketAddress::operator==(const CSocketAddress& rhs) const
{
	return rhs.m_port == m_port && rhs.m_address == m_address;
}

NNetLib::u32 NNetLib::CSocketAddress::CreateAddress(u8 a, u8 b, u8 c, u8 d)
{
	u32 newAddress = (a << 24) | (b << 16) | (c << 8) | d;
	return newAddress;
}